package model;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
@Entity
@Table(name="CLIENTE",schema="simos")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TIPO")


@NamedQueries( {
	@NamedQuery(name="findClienteByTel", query = "select c from Cliente c where c.telefone = ?1 and c.ddd = ?2"),
	@NamedQuery(name="findClienteByTelefone", query = "select c from Cliente c where c.telefone LIKE ?1"),
	@NamedQuery(name="findClienteByNome", query = "select c from Cliente c where upper(c.nome) like ?1"),

})

public abstract class Cliente implements ICpfCnpj{
	@TableGenerator(
			name="generatorCliente",
			pkColumnValue="SEQ_CLIENTE",
			allocationSize=1)
	@Id
 	@Column(name="CLIE_ID")
	@GeneratedValue(strategy=GenerationType.TABLE, generator = "generatorCliente")
	private Integer id;
	
	@Column(name="CLIE_NM_NOME", length = 100)
	private String nome;
	
	@Column(name="CLIE_TX_TELEFONE", length=9)
	private String telefone;
	
	@Column(name="CLIE_TX_DDD", length=2)
	private String ddd;
	
	@Column(name="CLIE_TX_ENDERECO", length=200)
	private String endereco;
	
	@Column(name="CLIE_TX_BAIRRO", length=50)
	private String bairro;
	
	@OneToMany(mappedBy="cliente")
	private Collection <OrdemServico> colOs;

	public String getNome() {
		return nome;
	}

	public Cliente() {
		super();
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getTelefone() {
		return telefone;
	}

	public void setTelefone(String telefone) {
		this.telefone = telefone;
	}

	public String getEndereco() {
		return endereco;
	}

	public void setEndereco(String endereco) {
		this.endereco = endereco;
	}

	public Collection<OrdemServico> getColOs() {
		return colOs;
	}

	public void setColOs(Collection<OrdemServico> colOs) {
		this.colOs = colOs;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getDdd() {
		return ddd;
	}

	public void setDdd(String ddd) {
		this.ddd = ddd;
	}

	public String getBairro() {
		return bairro;
	}

	public void setBairro(String bairro) {
		this.bairro = bairro;
	}
	 
}
 
